﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;

namespace Coleotrack.Data.Maps
{
    public class UserMap : ClassMap<User>
    {
        public UserMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();
            Map(x => x.Name).Not.Nullable().Unique();
            Map(x => x.Password).Length(32).Not.Nullable();
            Map(x => x.Email).Length(255).Not.Nullable().Unique();
            Map(x => x.Active).Not.Nullable();
            Map(x => x.Created).Not.Nullable();
            Map(x => x.PasswordRequestCode).Nullable();

            References(x => x.Profile).Cascade.SaveUpdate();

            HasManyToMany(x => x.Roles).Cascade.SaveUpdate();
        }
    }
}